﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BaseData.HelperBootStrap
{
    class TreeNodes
    {
        public string Get()
        {
            var list = new List<TreeRespVO>(); //后台根据父节点查询出的数据列表  
            var vo = new TreeRespVO();  
            var voItemList = new List<Item>();
            if (!list.Any()) return null;
            //Tree和数据库对应的实体bean对象  
            foreach (var lst in list)
            {

                var item = new Item();
                var child_count = 0; //根据遍历的节点，查询该节点子节点的个数。  
                //item.setText(lst.getNodeName());
                if (child_count > 0)
                {
                    item.setType("folder");//有子节点  
                    var adp = new AdditionalParameters();
                    //adp.setId(knowledgeTree.getId());
                    item.setAdditionalParameters(adp);
                }
                else
                {
                    var adp = new AdditionalParameters();
                    //adp.setId(knowledgeTree.getId());
                    adp.setItemSelected(true);
                    item.setAdditionalParameters(adp);
                    item.setType("item");//无子节点  
                }
                //voItemList.add(item);
            }
            //vo.setData( voItemList ); 
            return null;
        }
    }
    //功能: 数据返回对象 
    public class TreeRespVO
    {
        private List<Item> data = new List<Item>();
        public List<Item> getData()
        {
            return data;
        }
        public void setData(List<Item> data)
        {
            this.data = data;
        }
    }
    // 功能: 节点的信息 
    public class Item
    {
        /** 
        * 节点的名字 
        */
        private String text;

        /** 
        * 节点的类型："item":文件  "folder":目录 
        */
        private String type;

        /** 
        * 子节点的信息 
        */
        private AdditionalParameters additionalParameters;

        public String getText()
        {
            return text;
        }

        public void setText(String text)
        {
            this.text = text;
        }

        public String getType()
        {
            return type;
        }

        public void setType(String type)
        {
            this.type = type;
        }

        public AdditionalParameters getAdditionalParameters()
        {
            return additionalParameters;
        }

        public void setAdditionalParameters(AdditionalParameters additionalParameters)
        {
            this.additionalParameters = additionalParameters;
        }
    }
    // 功能: 子节点的信息 
    public class AdditionalParameters
    {
        // 子节点列表 
        private List<Item> children = new List<Item>();

        // 节点的Id 
        private String id;

        // 是否有选中属性 
        // @JsonProperty( "item-selected" )  
        private bool itemSelected;
        public bool isItemSelected()
        {
            return itemSelected;
        }
        public void setItemSelected(bool itemSelected)
        {
            this.itemSelected = itemSelected;
        }
        public List<Item> getChildren()
        {
            return children;
        }
        public void setChildren(List<Item> children)
        {
            this.children = children;
        }
        public String getId()
        {
            return id;
        }
        public void setId(String id)
        {
            this.id = id;
        }
    }
}
